from flask import Flask

app = Flask(__name__)
# 1.在请求开始前执行一次
@app.before_first_request
def func_first_request():
    print('before_first_request')

@app.before_request
def func_before_request():
    print('before_request')

@app.after_request
def func_after_request(response):
    print('after_request')
    return response

@app.teardown_request
def func_teardown_request(e):
    print('teardown_request')

@app.route('/')
def index():
    print('index')
    return 'index'

if __name__ == '__main__':
    app.run(debug=True)
